﻿using Microsoft.EntityFrameworkCore;
using Volo.Abp;
using Volo.Abp.EntityFrameworkCore.Modeling;

namespace Himp.Platform.Dc.EntityFrameworkCore;

public static class DcDbContextModelCreatingExtensions
{
    public static void ConfigureDc(
        this ModelBuilder builder)
    {
        Check.NotNull(builder, nameof(builder));

        #region Cores

        builder.Entity<BizSeq>(b =>
        {
            b.ToTable("BIZ_SEQ", DcDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        #endregion

        #region Diags

        builder.Entity<ClncDiagDict>(b =>
        {
            b.ToTable("DIAG_DICT", DcDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        builder.Entity<DiagTypeDict>(b =>
        {
            b.ToTable("DIAG_TYPE_DICT", DcDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        builder.Entity<HiDiagDict>(b =>
        {
            b.ToTable("HI_DIAG_DICT", DcDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        builder.Entity<TcmsympDict>(b =>
        {
            b.ToTable("TCMSYMP_DICT", DcDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        builder.Entity<TcmDiseDict>(b =>
        {
            b.ToTable("TCM_DISE_DICT", DcDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        #endregion

        builder.Entity<StdWordDict>(b =>
        {
            b.ToTable("STD_WORD_DICT", DcDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        builder.Entity<DrugMedcWay>(b =>
        {
            b.ToTable("DRUG_MEDC_WAY_DICT", DcDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        builder.Entity<InvChgTypeDict>(b =>
        {
            b.ToTable("INV_CHG_TYPE_DICT", DcDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        builder.Entity<OprnDict>(b =>
        {
            b.ToTable("OPRN_DICT", DcDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        builder.Entity<RxTypeDict>(b =>
        {
            b.ToTable("RX_TYPE_DICT", DcDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        builder.Entity<SplerDict>(b =>
        {
            b.ToTable("SPLER_DICT", DcDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        builder.Entity<StdDomainDict>(b =>
        {
            b.ToTable("STD_DOMAIN_DICT", DcDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        builder.Entity<StdPhrDict>(b =>
        {
            b.ToTable("STD_PHR_DICT", DcDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        builder.Entity<RxUsedFrqu>(b =>
        {
            b.ToTable("USED_FRQU_DICT", DcDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        #region 公共项目

        builder.Entity<PubItem>(b =>
        {
            b.ToTable("PUB_ITEM", DcDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        builder.Entity<PubItemType>(b =>
        {
            b.ToTable("PUB_ITEM_TYPE", DcDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        builder.Entity<ChrgitmType>(b =>
        {
            b.ToTable("CHRGITM_TYPE", DcDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        builder.Entity<ChrgitmTypeGrp>(b =>
        {
            b.ToTable("CHRGITM_TYPE_GRP", DcDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        #endregion

        #region 药品

        builder.Entity<DrugType>(b =>
        {
            b.ToTable("DRUG_TYPE", DcDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        builder.Entity<PhamType>(b =>
        {
            b.ToTable("PHAM_TYPE", DcDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        builder.Entity<DrugDosform>(b =>
        {
            b.ToTable("DRUG_DOSFORM", DcDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        builder.Entity<DrugMedcWay>(b =>
        {
            b.ToTable("DRUG_MEDC_WAY", DcDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        builder.Entity<DrugPrdr>(b =>
        {
            b.ToTable("DRUG_PRDR", DcDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        #endregion

        #region 处方

        builder.Entity<RxUsedFrqu>(b =>
        {
            b.ToTable("RX_USED_FRQU", DcDbProperties.DbSchema);
            b.ConfigureByConvention();
        });

        #endregion

        /* Configure all entities here. Example:

        builder.Entity<Question>(b =>
        {
            //Configure table & schema name
            b.ToTable(DcDbProperties.DbTablePrefix + "Questions", DcDbProperties.DbSchema);

            b.ConfigureByConvention();

            //Properties
            b.Property(q => q.Title).IsRequired().HasMaxLength(QuestionConsts.MaxTitleLength);

            //Relations
            b.HasMany(question => question.Tags).WithOne().HasForeignKey(qt => qt.QuestionId);

            //Indexes
            b.HasIndex(q => q.CreationTime);
        });
        */
    }
}
